﻿/**********************************************************************
* @file   FITKAcousticsFEFaceMgrAdaptor.h
* @brief  面管理器数据读写适配器
* @author yangjing (1195810980@qq.com)
* @date   2025-02-25
*********************************************************************/

#ifndef _FITFK_ACOUSTICS_FE_FACE_MANAGER_ADAPTOR_H___
#define _FITFK_ACOUSTICS_FE_FACE_MANAGER_ADAPTOR_H___

#include "FITKAcousticsAbstractAdaptor.h"
#include "FITK_Kernel/FITKCore/FITKCoreMacros.h"
#include "FITK_Kernel/FITKAdaptor/FITKIOAdaptorFactory.h"
#include <H5Cpp.h>
namespace IO {
    class FITKHDF5FileTool;
}

namespace Acoustics {
    class FITKAcousticsFEFaceManager;
    class FITKAcousticsFEFace;
    class FITKAcousticsTriangles;
}

namespace IO
{
    class FITKAcousticsHDF5IOAPI FITKAcousticsFEFaceMgrAdaptor : public FITKAcousticsAbsAdaptor
    {
    public:
        explicit FITKAcousticsFEFaceMgrAdaptor() = default;
        virtual ~FITKAcousticsFEFaceMgrAdaptor() = default;

        virtual bool adaptR() override;

        virtual bool adaptW() override;
    private:
        /**
        * @brief 写FE面数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  FEFaceManager   FE面管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2025-2-10
        */
        bool writeFEFaceMgr(H5::Group &gp, Acoustics::FITKAcousticsFEFaceManager* FEFaceManager);


        /**
        * @brief 读FE面数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  FEFaceManager   FE面管理器
        * @author yangjing (1195810980@qq.com)
        * @date 2025-2-10
        */
        bool readFEFaceMgr(H5::Group &gp, Acoustics::FITKAcousticsFEFaceManager* FEFaceManager);

    private:
        /**
        * @brief 写一个三角形列表
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  TriangleMesh    三角形列表数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-2-10
        */
        bool writeTriangleMesh(H5::Group& gp, Acoustics::FITKAcousticsTriangles*TriangleMesh);





        /**
        * @brief 读三角形列表写入面中
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  faceP    一个面的指针
        * @author yangjing (1195810980@qq.com)
        * @date 2024-2-10
        */
        bool readTriangleMesh(H5::Group &gp, Acoustics::FITKAcousticsFEFace *faceP);

        /**
        * @brief 写FE面父类数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  sys   抽象父类数据
        * @author yangjing (1195810980@qq.com)
        * @date 2024-2-10
        */
        bool writeParent(H5::Group&gp, Acoustics::FITKAcousticsFEFace* sys);


        /**
        * @brief 读FE面父类数据
        * @param @param[i]  gp hdf5组别
        * @param @param[i]  sys   抽象父类数据
        * @author yangjing (1195810980@qq.com)
        * @date 2025-1-23
        */
        bool readParent(H5::Group&gp, Acoustics::FITKAcousticsFEFace* sys);

    private:
        bool m_isinit = false;//判断m_TriangleAllElementData是否已经分配内存了
        std::vector<std::vector<int>>m_TriangleAllElementData;//[0]为ID  [1][2][3]节点  复用容器
        IO::FITKHDF5FileTool*m_toolp{ nullptr };
    };
    Register2FITKIOAdaptorFactory(FITKAcousticsHDF5, Acoustics::FITKAcousticsFEFaceManager, FITKAcousticsFEFaceMgrAdaptor);
}
#endif
